package exception_;

import java.util.Scanner;

public class EcmDef {
    public static void main(String[] args) {
        try {
            if (args.length != 2){
                throw new ArrayIndexOutOfBoundsException("参数个数不对");
            }
            int n1 = Integer.parseInt(args[0]);
            int n2 = Integer.parseInt(args[1]);

            int res = cal(n1, n2);
            System.out.println("res = " + res);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println(e.getMessage());
        } catch (NumberFormatException e) {
            System.out.println("参数格式不正确:" + e.getMessage());
        } catch (ArithmeticException e){
            System.out.println("出现除零异常");
        }
    }

    public static int cal(int a, int b){
        return a/ b;
    }
}
